﻿@using System.Text
@using OA.Model
@using OA.AspNetCore.Html
@using OA.Core.Model
@using OA.Core.Helper

@model EmployeePosition
@{
    ViewBag.Title = "岗位管理";
    Layout = "~/Areas/Member/Views/Shared/_form_layout.cshtml";

    string msg = ViewBag.Msg;
    string tips = string.Empty;
    if (!string.IsNullOrWhiteSpace(msg))
    {
        tips = $"layer.msg('{msg}');";
    }
    int departmentID = ViewBag.DepartmentID;
    string errorMsg = ViewBag.Msg;
}

<div class="layui-form layui-tab-content" id="LAY_ucm" style="padding:0px">
    @if (!string.IsNullOrWhiteSpace(errorMsg))
    {
        <blockquote class="layui-elem-quote">@errorMsg</blockquote>
    }
    else
    {
        @using (Html.BeginForm(FormMethod.Post, htmlAttributes: new { @class = "layui-form", id = "myForm" }))
        {
            @Html.AntiForgeryToken()
            <input type="hidden" name="EmpID" value="@Model.EmpID" />
            <div class="layui-form-item">
                <label class="layui-form-label" for="StartTime">开始时间</label>
                <div class="layui-input-block">
                    <input type="text" name="StartTime" id="StartTime" data-type="date" lay-verify="date" value="@Model.StartTime" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input mydate" data-format="yyyy-MM-dd">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" for="EndTime">结束时间</label>
                <div class="layui-input-block">
                    <input type="text" name="EndTime" id="EndTime" lay-verify="date"  data-type="date" value="@Model.EndTime" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input mydate" data-format="yyyy-MM-dd">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" for="MyDepartments">部门</label>
                <div class="layui-input-block MyDepartments">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" for="Position">岗位</label>
                <div class="layui-input-block">
                    <select name="PositionID" id="PositionID"></select>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block" style="text-align:right;">
                    <input type="submit" value="提 交" lay-submit="" lay-filter="OAForm" class="layui-btn mySubmit" />
                </div>
            </div>
        }

    }
</div>
<script type="text/javascript" src="/Member/Home/GetDepartmentAndPosition"></script>
<script type="text/javascript" src="@ViewBag.OssUrl/front/js/department.js"></script>
<script type="text/javascript">
    layui.use(['form', 'layedit', 'autocomplete', 'element', 'layer', 'laydate'], function () {
        form = layui.form;
        layer = layui.layer;
        element = layui.element;
        form.on('select(Department)', function (data) {
            InitDepartment($(".MyDepartments"), data.value);
            var currentDepartmentID = data.value;
            if (data.value == "0") {
                if ($(".Department").length > 0) {
                    currentDepartmentID = $(".Department").eq($(".Department").length - 2).val();
                }
            }
            InitPosition($("#PositionID"), currentDepartmentID, 0);
            form.render('select');
        });
    });
    InitDepartment($(".MyDepartments"), @departmentID);
    InitPosition($("#PositionID"), @departmentID,@Model.PositionID);
</script>

